package gui;

import javax.swing.JTextArea;

public class Console {
	private JTextArea terminal;

	public Console() {
		this.terminal = null;
	}

	public Console(JTextArea jta) {
		this.terminal = jta;
	}

	public void println() {
		this.print("\n");
	}

	public void println(String str) {
		this.print(str + "\n");
	}

	public void print(String str) {
		if (this.terminal == null) {
			System.out.print(str);
		} else {
			this.terminal.append(str);
			this.terminal.setCaretPosition(this.terminal.getDocument()
					.getLength());
		}
	}

	public void reset() {
		if (this.terminal != null) {
			this.terminal.setText("");
		}
	}
}
